import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/data/entities/application/special_list/process_list_entity.dart';
import 'package:enterprise_v6_app/app/modules/application/special_operation/special_list/process_allocation_page/process_allocation_controller.dart';

/// 流程模板页面
class ProcessAllocationPage extends StatelessWidget {
  ProcessAllocationPage({super.key});

  final controller = Get.put(ProcessAllocationController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar(
        titleText: '流程模板',
      ),
      body: GetBuilder(
          init: controller,
          builder: (_) {
            return Container(
              padding: EdgeInsets.only(left: 16.w, right: 16.w, top: 10.w),
              margin: EdgeInsets.only(bottom: 60.w),
              alignment: Alignment.topCenter,
              color: const Color(0xffF5F5F6),
              child: CustomEasyRefreshList<ProcessListEntity>(
                isShowSearch: true,
                dataLoad: controller.getData,
                itemBuilder: (ProcessListEntity item, int index) {
                  return Container(
                      padding: EdgeInsets.symmetric(
                          horizontal: 12.w, vertical: 16.w),
                      decoration: item.getIsChecked()
                          ? BoxDecoration(
                              borderRadius: BorderRadius.circular(8.w),
                              gradient: const LinearGradient(
                                  //渐变位置
                                  begin: Alignment.centerLeft,
                                  end: Alignment.centerRight,
                                  //渐变颜色[始点颜色, 结束颜色]
                                  colors: [
                                    Color(0xff3B62FF),
                                    Color(0xff9FB2FF)
                                  ]))
                          : BoxDecoration(
                              color: Colors.white,
                              borderRadius: BorderRadius.circular(8.w)),
                      child: Row(
                        children: [
                          item.getIsChecked()
                              ? SvgPicture.asset(
                                  AppImages.icon_process_select,
                                  width: 28.w,
                                  height: 28.w,
                                )
                              : SvgPicture.asset(
                                  AppImages.icon_process_un_select,
                                  width: 28.w,
                                  height: 28.w,
                                ),
                          AppGaps.hGap12,
                          Text(
                            item.getShowName(),
                            style: TextStyle(
                                color: item.getIsChecked()
                                    ? const Color(0xffffffff)
                                    : const Color(0xff262F38),
                                height: 1.2,
                                fontWeight: FontWeight.w400,
                                fontSize: 16.sp),
                          ),
                          const Spacer(),
                          Row(
                            children: [
                              Text(
                                '详情',
                                style: TextStyle(
                                  color: item.getIsChecked()
                                      ? const Color(0xffffffff)
                                      : AppColors.font_color_blue,
                                  height: 1.2,
                                  fontWeight: FontWeight.w400,
                                  fontSize: 16.sp,
                                ),
                              ),
                              AppGaps.hGap6,
                              Container(
                                decoration: BoxDecoration(
                                  color: item.getIsChecked()
                                      ? const Color(0xffffffff)
                                      : AppColors.font_color_blue,
                                  borderRadius: BorderRadius.circular(8.w),
                                ),
                                child: Icon(
                                  Icons.chevron_right,
                                  size: 16.w,
                                  color: item.getIsChecked()
                                      ? AppColors.font_color_blue
                                      : const Color(0xffffffff),
                                ),
                              ),
                            ],
                          ).click(() {
                            controller.showDetailDialog(item);
                          })
                        ],
                      )).clickOnce(() {
                    controller.onTap(item);
                  });
                },
              ),
            );
          }),
      bottomSheet: Container(
        height: 50.w,
        width: double.infinity,
        color: Colors.white,
        padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 5.w),
        child: ElevatedButton(
          style: ElevatedButton.styleFrom(
            backgroundColor: AppColors.blue_button,
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(22.r),
            ),
          ),
          onPressed: controller.nextStep,
          child: Text(
            '下一步',
            style: TextStyle(
              fontSize: 16.sp,
              color: Colors.white,
            ),
          ),
        ),
      ),
    );
  }
}
